﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="msg_receive_list.aspx.cs" Inherits="Ccit.SysPlat.Remind.msg_receive_list" %>

<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView"
    TagPrefix="dxwgv" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>在线消息-已接收消息</title>
    <script language="javascript" src="../script/jquery.js" type="text/javascript"></script>
    <script language="javascript" src="../script/StringClass_Ext.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jsonlib.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../script/jbase64.js"></script>
    
    <script type="text/javascript" language="javascript">
    
      /* 转发消息 */
      function doForword(vMsgId)
      {
         PageMethods.OperMsg(vMsgId,"","","Forword",ClientCallBack);
      }
      
      /* 回复 */
      function doReply(vMsgId,vReceiver)
      {
         PageMethods.OperMsg(vMsgId,vReceiver,"","Reply",ClientCallBack);
      }
      
      /* 查询 */
      function GetFuzzy()
      {
          __doPostBack("lnkSearch","");
      }
      
      /* 查看消息 */
      function doViewMsg(vMsgId,vSenderId,vCurCount)
      {
         PageMethods.OperMsg(vMsgId,vSenderId,vCurCount,"ViewMsg",ClientCallBack);
      }
      
      /* 删除 */
      function doDelete()
      {
        var vMsgIds = document.getElementById("hdIds").value;
        if(vMsgIds == "")
        {
            alert("请选择要删除的消息！");
            return;
        }
        else
        {
            if(confirm("确认要删除选择的消息？"))
                PageMethods.ReadMsg(vMsgIds,"DELETE",ClientCallBack);
        }
      }
      
      /* 已读 */
      function doRead()
      {
         var vMsgIds = document.getElementById("hdIds").value;
        if(vMsgIds == "")
        {
            alert("请选择要阅读的消息！");
            return;
        }
        else
        {
            if(confirm("确认要至选择的消息为已读?"))
                PageMethods.ReadMsg(vMsgIds,"READ",ClientCallBack);
        }
      }
      
      /* 折叠 */
      function doCollapse()
      {
         var tabCtrl = document.getElementById("tabQuery");
         var tabAttr = tabCtrl.style.display;
         if(tabAttr == "none")
           tabCtrl.style.display = "block";
         else
           tabCtrl.style.display = "none";
      }
      
      function ClientCallBack(vResult) {
          if (vResult == null || vResult == "") return;
//         var ResultArr = vResult.split("_");
          //         var vFlag =  ResultArr[0];
          eval("var resultObj=" + vResult);
          var operType = resultObj.operType;
          switch (operType)
         {
             case "Forword":  //转发
                 var msgId = resultObj.msgId;
                 var vPageParam = "MsgId=" + msgId + "&PageSource=1";
                 var encodeParam = base64encode(vPageParam);
                 OpenWindow("msg_send_edit.aspx?" + encodeParam, "", "600", "600");
                 break;
             case "Reply":    //回复
                 var receiverId = resultObj.receiverId;
                 var vPageParam = "RecevierId=" + receiverId + "&PageSource=1";
                 var encodeParam = base64encode(vPageParam);
                 OpenWindow("msg_receive_back.aspx?" + encodeParam, "", "500", "380");
                 break;
             case "ViewMsg":
                 var msgId = resultObj.msgId;
                 var receiverId = resultObj.receiverId;
                 var curCount = resultObj.curCount;
                 var vPageParam = "MsgId=" + msgId + "&receiverId=" + receiverId + "&curCount=" + curCount + "&PageSource=1";
                 // var vPageParam = "MsgId="+ResultArr[1]+"&receiverId="+ResultArr[2]+"&curCount=1&PageSource=3";                
                 var encodeParam = base64encode(vPageParam);
                 OpenWindow("msg_receive_view.aspx?" + encodeParam, "", "500", "380");
                 break;
            case "DELETE":
                var flag = resultObj.flag;
                if (flag > 0) {
                    alert("删除成功");
                    document.location = "msg_receive_list.aspx";
                }
                else {
                    alert("系统忙,请稍候再试");
                }
                break;
            case "READ":
                var flag = resultObj.flag;
                if (flag > 0)
                {
                  alert("设置成功");
                  document.location = "msg_receive_list.aspx";
                }
                else {alert("系统忙,请稍候再试");}
                break;
         }
      }
    </script>
    
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    
    <input type="hidden" id="hdIds" runat="server" />
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:LinkButton ID="lnkSearch" runat="server" Visible="false" onclick="lnkSearch_Click"></asp:LinkButton>
    <table cellpadding="0" cellspacing="0" class="tbToolbar" width="98%" align="center">
      <tr>
        <td align="left">
          <div class="tbSeparator"></div>
        </td>
        <td width="95%" class="titlebar">在线消息-已接收消息</td>
        <td width="5%">
            <a href="javascript:doCollapse()" class="linktext" title="折叠"><img src="../images/hidemenu.gif"/></a>
        </td>
        <td align="right">
          <div class="tbSeparator"></div>
        </td>
      </tr>
    </table>
   
    <table id="tabQuery" cellpadding="0" runat="server" cellspacing="0" align="center" width="98%"  height="5px" style="margin-top:3px">
     <tr>
       <td>
          <fieldset style="width:100%">
             <table cellpadding="0" cellspacing="0" width="100%" align="center" height="3px" >
              <tr>
                <td>
                 <nobr>
                  内容 <input type="text" runat="server"  class="input" id="txtContent"  style="width:80px"/>
                 </nobr> 
                </td>
                <td>
                  <nobr> 
                   状态 <asp:CheckBox ID="cbkRead" runat="server"  CssClass="checkbox"/>已读
                    <asp:CheckBox ID="cbkUnRead" runat="server"   CssClass="checkbox"/>未读
                  </nobr>
                </td>
                <td>
                  <nobr>
                    发送人 <input type="text" runat="server" id="txtSender"  class="input"  style="width:80px"/>
                  </nobr>
                </td>
                <td>
                   <nobr>
                    发送时间 <input type="text" runat="server" id="txtBeginTime"  class="input"  style="width:90px" readonly/>
                    <IMG class="getdate" id="IMG1" title="选择日期" src="../images/toolbar/Calendar.gif" relaobj="txtBeginTime">
                   </nobr>
                </td>
                <td>
                  <nobr>
                     到 <input type="text" runat="server" id="txtEndTime"  class="input"   style="width:90px"  readonly/>
                    <IMG class="getdate" id="IMG2" title="选择日期" src="../images/toolbar/Calendar.gif" relaobj="txtEndTime">
                  </nobr>  
                </td>
                <td>
                   <nobr>
                      <a href="javascript:GetFuzzy()" title="查询" class="linktext">
                            <img src="../images/toolbar/search.gif" />
                        </a>
                    </nobr>
                </td>
              </tr>
             </table>
          </fieldset>
       </td>
     </tr>
    </table>
    
    
    <table cellpadding="0" cellspacing="0" align="center" width="98%"  height="5px" style="margin-top:3px;">
      <tr>
        <td style="width:6%">
         <nobr>
          图例:
         </nobr> 
        </td>
        <td style="width:78%" align="left">
          <nobr> 
            <img src="../images/toolbar/Unread.gif" />未读消息 &nbsp;
            <img src="../images/toolbar/read.gif" />已读消息/置为已读&nbsp;
            <img src="../images/toolbar/reply.GIF" />回复&nbsp;
            <img src="../images/toolbar/turn.GIF" />转发&nbsp;
            <img src="../images/toolbar/delete.gif" />删除
          </nobr>
        </td>
        <td style="width:5%" align="center">
          <nobr>
             <a href="javascript:doRead()" class="linktext" title="置为已读"><img src="../images/toolbar/read.gif" /></a>
          </nobr>  
        </td>
        <td style="width:5%" align="center">
           <nobr>
              <a href="javascript:doDelete()" class="linktext"  title="删除"><img src="../images/toolbar/delete.gif" /></a>
            </nobr>
        </td>
      </tr>
    </table>
    
    
    <table cellpadding="0" cellspacing="0" width="98%" border="0" align="center" valign="top" style="margin-top:3px;">
      <tr>
        <td>
          <dxwgv:ASPxGridView ID="gvReceiveMsg" runat="server" Width="100%" align="center" 
                KeyFieldName="MsgId" onhtmlrowcreated="gvReceiveMsg_HtmlRowCreated">
            <Columns>
                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="3%">
                    <HeaderTemplate>
                        <input id="chkCheck"  class="checkbox" type="checkbox" runat="server" onclick="gvReceiveMsg.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Select/Unselect all rows on the page"></input>
                    </HeaderTemplate>
                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" HorizontalAlign="Center">
                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                    </HeaderStyle>
                </dxwgv:GridViewCommandColumn>
                <dxwgv:GridViewDataTextColumn Caption="状态" FieldName="ReadFlag" VisibleIndex="0" Width="8%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="内容" FieldName="SendContent" VisibleIndex="1" Width="40%">
                    <HeaderStyle HorizontalAlign="Center"/>
                    <CellStyle HorizontalAlign="left"  Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="类型" FieldName="MsgType" VisibleIndex="2" Width="10%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发送人" FieldName="SenderId" VisibleIndex="3" Width="10%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="发送时间" FieldName="SendTime" VisibleIndex="4" Width="17%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center" Wrap="False"></CellStyle>
                </dxwgv:GridViewDataTextColumn>
                
                <dxwgv:GridViewDataTextColumn Caption="操作" VisibleIndex="5" Width="10%">
                    <HeaderStyle HorizontalAlign="Center" />
                    <CellStyle HorizontalAlign="Center"></CellStyle>
                    <DataItemTemplate>
                        <a id="haModify" runat="server" title="回复"><img src="../images/toolbar/reply.GIF" /></a>&nbsp;
                        <a id="haDelete" runat="server" title="转发"><img src="../images/toolbar/turn.GIF" /></a>
                    </DataItemTemplate>
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <SettingsPager AlwaysShowPager="True" PageSize="10">
                <FirstPageButton Visible="True">
                </FirstPageButton>
                <LastPageButton Visible="True">
                </LastPageButton>
            </SettingsPager>
            <Styles>
                <Row CssClass=""></Row>
                <AlternatingRow  CssClass="" Enabled="true"/>
                <SelectedRow  CssClass=""></SelectedRow>
            </Styles>
            <%-- 复选框选择脚本事件 --%>
            <ClientSideEvents SelectionChanged="function(s,e){OnGridSelectionChanged();}"/>
             <%-- 可调整列宽--%>
                <SettingsBehavior ColumnResizeMode="Control" />
           </dxwgv:ASPxGridView>
        </td>
      </tr>
    </table>
    <script language="javascript" type="text/javascript">
        <!--
        ///复选框选择
        function OnGridSelectionChanged(){
            gvReceiveMsg.GetSelectedFieldValues("MsgId",OnGridSelectionComplete);
        }
        
        function OnGridSelectionComplete(values){
            document.getElementById("hdIds").value = values;
        }
        //-->
    </script>

    </ccit:ActionForm>
</body>
</html>
